/****************************************************************************\
 *
 *
 *			DEBUGGING or PRINTING ZONE
 *
 *
 ****************************************************************************/

#include <assert.h>
#include "debug.h"
#include "common.h"

namespace Tablebases
{

#if defined(DEBUG) || defined(FOLLOW_EGTB)

	static const char *Square_str[64] = {
 		"a1","b1","c1","d1","e1","f1","g1","h1",
 		"a2","b2","c2","d2","e2","f2","g2","h2",
 		"a3","b3","c3","d3","e3","f3","g3","h3",
 		"a4","b4","c4","d4","e4","f4","g4","h4",
 		"a5","b5","c5","d5","e5","f5","g5","h5",
 		"a6","b6","c6","d6","e6","f6","g6","h6",
 		"a7","b7","c7","d7","e7","f7","g7","h7",
 		"a8","b8","c8","d8","e8","f8","g8","h8"
	};

	static const char *P_str[] = {
		"--", "P", "N", "B", "R", "Q", "K"
	};

#endif

#if defined(FOLLOW_EGTB)

	static const char *Info_str[8] = {	
		" Draw", " Wmate", " Bmate", "Illegal", 
		"~Draw", "~Wmate", "~Bmate", "Unknown" 
	};

#endif


static void 	fatal_error(void) {
    //exit(EXIT_FAILURE);
	assert(0);
}


#if defined(DEBUG) 
static void
print_pos (const sq_t *ws, const sq_t *bs, const pc_t *wp, const pc_t *bp)
{
	int i;
	printf ("White: ");
	for (i = 0; ws[i] != NOSQUARE; i++) {
		printf ("%s%s ", P_str[wp[i]], Square_str[ws[i]]);	
	}
	printf ("\nBlack: ");
	for (i = 0; bs[i] != NOSQUARE; i++) {
		printf ("%s%s ", P_str[bp[i]], Square_str[bs[i]]);	
	}
	printf ("\n");
}
#endif

#if defined(DEBUG) || defined(FOLLOW_EGTB)
static void
output_state (unsigned stm, const SQUARE *wSQ, const SQUARE *bSQ, 
								const SQ_CONTENT *wPC, const SQ_CONTENT *bPC)
{
	int i;
	assert (stm == WH || stm == BL);
	
	printf("\n%s to move\n", stm==WH?"White":"Black");
	printf("W: ");
	for (i = 0; wSQ[i] != NOSQUARE; i++) {
		printf("%s%s ", P_str[wPC[i]], Square_str[wSQ[i]]);
	} 				
	printf("\n");
	printf("B: ");	
	for (i = 0; bSQ[i] != NOSQUARE; i++) {
		printf("%s%s ", P_str[bPC[i]], Square_str[bSQ[i]]);
	} 
	printf("\n\n");
}
#endif


//static void
//list_index (void)
//{
//	enum  {START_GTB = 0, END_GTB = (MAX_EGKEYS)};
//	int i; 
//	index_t accum = 0;
//	printf ("\nIndex for each GTB\n");
//		printf ("%3s: %7s  %7s   %7s   %7s\n" , "i", "TB", "RAM-slice", "RAM-max", "HD-cumulative");	
//	for (i = START_GTB; i < END_GTB; i++) { 
//		index_t indiv_k  = egkey[i].maxindex * (index_t)sizeof(dtm_t) * 2/1024;
//		accum += indiv_k;
//		printf ("%3d: %7s %8luk %8luk %8luM\n", i, egkey[i].str, (long unsigned)(indiv_k/egkey[i].slice_n), 
//													(long unsigned)indiv_k, (long unsigned)accum/1024/2);	
//	}
//	printf ("\n");	
//	return;
//}


}
